package com.qqt.csr.common.config;

import com.qqt.csr.common.mongo.DateToStringConverter;
import com.qqt.csr.common.mongo.LongToStringConverter;
import com.qqt.csr.common.mongo.StringToDateConverter;
import com.qqt.csr.common.mongo.StringToLongConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;

@Configuration
public class MongoConfig {

    @Bean
    public MongoCustomConversions mongoCustomConversions() {
        return MongoCustomConversions.create(mongoConverterConfigurationAdapter -> {
            mongoConverterConfigurationAdapter.registerConverter(new LongToStringConverter());
            mongoConverterConfigurationAdapter.registerConverter(new StringToLongConverter());
            mongoConverterConfigurationAdapter.registerConverter(new DateToStringConverter());
            mongoConverterConfigurationAdapter.registerConverter(new StringToDateConverter());
        });
    }
}
